package com.cacho.s2b.lesson.cucumber;

import com.cacho.s2b.lesson.engine.ApiTestSender;
import org.apache.commons.lang3.StringUtils;

import java.util.ArrayList;
import java.util.List;

/**
 * @Description 封装一些基础的glue步骤
 * @Author LingWei
 * @date 2023/12/31
 **/
public class cucumberStep {
    protected static final List<ApiTestSender> senders = new ArrayList<>(); // 所有测试发送信息
    // 根据测试场景id 获取测试案例信息
    public ApiTestSender getSender (String scenarioId){
        ApiTestSender sender = new ApiTestSender(scenarioId);
        sender.setScenarioId(scenarioId);
        if (StringUtils.isEmpty(scenarioId)){
            return sender;
        }
        for (ApiTestSender tempSender : senders){
            if (tempSender.getScenarioId().equalsIgnoreCase(scenarioId)){
                return tempSender;
            }
        }
        senders.add(sender);
        return sender;
    }
}
